From 0b9222eba64eb5313d28984962a367e17b3d935b Mon Sep 17 00:00:00 2001 From: netconomy Date: Fri, 17 Aug 2007 06:24:37 +0000 Subject: deprecated code git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@170 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../knowcenter/wag/egov/egiz/test/AbsTexTest.java | 124 -------- .../at/knowcenter/wag/egov/egiz/test/BinSig.java | 345 --------------------- .../wag/egov/egiz/test/ExtractTextTextual.java | 56 ---- .../at/knowcenter/wag/egov/egiz/test/X509.java | 40 --- .../at/knowcenter/wag/egov/egiz/test/X509Ext.java | 48 --- 5 files changed, 613 deletions(-) delete mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/test/AbsTexTest.java delete mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/test/BinSig.java delete mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/test/ExtractTextTextual.java delete mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/test/X509.java delete mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/test/X509Ext.java (limited to 'src/main/java') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/test/AbsTexTest.java b/src/main/java/at/knowcenter/wag/egov/egiz/test/AbsTexTest.java deleted file mode 100644 index 7788a2a..0000000 --- a/src/main/java/at/knowcenter/wag/egov/egiz/test/AbsTexTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * - */ -package at.knowcenter.wag.egov.egiz.test; - - -/** - * Test file for testing the absolute text signature. - * - * @deprectated outdated - * @author wprinz - */ -public class AbsTexTest -{ - -// /** -// * The logger definition. -// */ -// private static final Logger logger = ConfigLogger.getLogger(AbsTexTest.class); -// -// /** -// * @param args -// * @throws IOException -// * @throws PresentableException -// */ -// public static void main(String[] args) throws IOException, PresentableException -// { -// SettingsReader.initializeForCommandLine(); -// PropertyConfigurator.configure(SettingsReader.CONFIG_PATH + "log4j.properties"); -// -// File BASE_DIR = new File("C:\\wprinz\\Filer\\egiz\\docs\\abstexsig"); -// File original_file = new File(BASE_DIR, "AbsTexSig.pdf"); -// File signed_file = new File(BASE_DIR, "AbsTexSig.pdf_out.pdf"); -// File signed_signed_file = new File(BASE_DIR, "AbsTexSig.pdf_out.pdf_out.pdf"); -// -// File in = new File("C:\\wprinz\\Filer\\egiz\\docs\\Abnahmetests\\tests\\commandline\\alte_sig\\document4.pdf_asimoaold.pdf_out.pdf"); -// byte[] pdf = readInFile(in); -// -// ByteArrayInputStream bais = new ByteArrayInputStream(pdf, 0, pdf.length); -// String raw_text = TextualSignature.extractTextTextual(bais); -// -// String text = PdfAS.extractNormalizedTextTextual(pdf, pdf.length); -// -// writeTextToFile(raw_text, new File(BASE_DIR, "raw_text.utf8.txt")); -// writeTextToFile(text, new File(BASE_DIR, "text.utf8.txt")); -// -// if (true) -// { -// return; -// } -// -// String[] texts = new String[3]; -// -// byte[] original = readInFile(original_file); -// byte[] signed = readInFile(signed_file); -// byte[] signed2 = readInFile(signed_signed_file); -// -// texts[0] = PdfAS.extractNormalizedTextTextual(original, original.length); -// texts[1] = PdfAS.extractNormalizedTextTextual(signed, signed.length); -// texts[2] = PdfAS.extractNormalizedTextTextual(signed2, signed2.length); -// -// writeTextToFile(texts[0], new File(BASE_DIR, "original.utf8.txt")); -// writeTextToFile(texts[1], new File(BASE_DIR, "signed.utf8.txt")); -// writeTextToFile(texts[2], new File(BASE_DIR, "signed_signed.utf8.txt")); -// -// // String text = texts[2]; -// -// List holders = AbsoluteTextSignature.extractSignatureHoldersFromText(text); -// logger.debug("extracted " + holders.size() + " holders:"); -// for (int i = 0; i < holders.size(); i++) -// { -// SignatureHolder holder = (SignatureHolder) holders.get(i); -// -// logger.debug(" #" + i + ": " + holder.getSignatureObject().getSignationDate() + ", " + holder.getSignatureObject().getSignatureTypeDefinition().getType()); -// } -// -// SignatureHolder sh_latest = (SignatureHolder) holders.get(1); -// -// SignatureHolder sh_earlier = (SignatureHolder) holders.get(0); -// -// writeTextToFile(sh_latest.getSignedText(), new File(BASE_DIR, "reconstructed_latest.utf8.txt")); -// writeTextToFile(sh_earlier.getSignedText(), new File(BASE_DIR, "reconstructed.utf8.txt")); -// -// verifyReconstruction(sh_latest.getSignedText(), texts[1]); -// verifyReconstruction(sh_earlier.getSignedText(), texts[0]); -// -// SignatureResponse sr = PdfAS.verify(sh_latest, "moa"); -// System.out.println(sr); -// sr = PdfAS.verify(sh_earlier, "moa"); -// System.out.println(sr); -// -// } -// -// public static byte[] readInFile(File file) throws IOException -// { -// FileInputStream fis = new FileInputStream(file); -// byte[] ba = new byte[(int) file.length()]; -// fis.read(ba); -// fis.close(); -// return ba; -// } -// -// public static void writeTextToFile(String text, File file) throws IOException -// { -// FileOutputStream fos = new FileOutputStream(file); -// OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); -// osw.write(text); -// osw.close(); -// } -// -// public static void verifyReconstruction(String reconstructed_text, -// String expected_text) -// { -// if (reconstructed_text.equals(expected_text)) -// { -// System.out.println("TEXT MATCHED OK!"); -// } -// else -// { -// System.err.println("TEXT DIDN'T MATCH!!!!!!!"); -// } -// } - -} diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/test/BinSig.java b/src/main/java/at/knowcenter/wag/egov/egiz/test/BinSig.java deleted file mode 100644 index 612ada1..0000000 --- a/src/main/java/at/knowcenter/wag/egov/egiz/test/BinSig.java +++ /dev/null @@ -1,345 +0,0 @@ -/** - * Copyright (c) 2006 by Know-Center, Graz, Austria - * - * This software is the confidential and proprietary information of Know-Center, - * Graz, Austria. You shall not disclose such Confidential Information and shall - * use it only in accordance with the terms of the license agreement you entered - * into with Know-Center. - * - * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF - * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR - * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY - * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. - * - * $Id: BinSig.java,v 1.1 2006/10/31 08:19:52 wprinz Exp $ - */ -package at.knowcenter.wag.egov.egiz.test; - -import java.awt.Color; -import java.io.ByteArrayOutputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException; -import at.knowcenter.wag.egov.egiz.pdf.Placeholder; -import at.knowcenter.wag.egov.egiz.pdf.SplitStrings; -import at.knowcenter.wag.egov.egiz.pdf.StringInfo; - -import com.lowagie.text.BadElementException; -import com.lowagie.text.Chunk; -import com.lowagie.text.Document; -import com.lowagie.text.DocumentException; -import com.lowagie.text.Font; -import com.lowagie.text.FontFactory; -import com.lowagie.text.Paragraph; -import com.lowagie.text.Phrase; -import com.lowagie.text.Rectangle; -import com.lowagie.text.pdf.BaseFont; -import com.lowagie.text.pdf.PdfContentByte; -import com.lowagie.text.pdf.PdfIndirectReference; -import com.lowagie.text.pdf.PdfPCell; -import com.lowagie.text.pdf.PdfPTable; -import com.lowagie.text.pdf.PdfTemplate; -import com.lowagie.text.pdf.PdfWriter; - -/** - * @author wprinz - */ -public class BinSig -{ - - public static final String KEY_DATE = "Datum ÖÄÜ:"; - - public static final String KEY_SN = "Seriennummer öäü:"; - - public static final String KEY_SIGVAL = "Signaturwert ß:"; - - public static final String KEY_ISSUER = "Aussteller .,!?:"; - - /** - * @param args - * @throws DocumentException - * @throws IOException - * @throws PDFDocumentException - */ - public static void main(String[] args) throws DocumentException, IOException, PDFDocumentException - { - BinSig bs = new BinSig(); - bs.action(); - } - - public void action() throws IOException, DocumentException, PDFDocumentException - { - Document.compress = false; - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - Document document = new Document(); - PdfWriter writer = PdfWriter.getInstance(document, baos); - - document.open(); - - Paragraph p1 = new Paragraph(new Chunk("This is my first paragraph. ", FontFactory.getFont(FontFactory.HELVETICA, 10))); - p1.add("The leading of this paragraph is calculated automagically. "); - p1.add("The default leading is 1.5 times the fontsize. "); - p1.add(new Chunk("You can add chunks ")); - p1.add(new Phrase("or you can add phrases. ")); - p1.add(new Phrase("Unless you change the leading with the method setLeading, the leading doesn't change if you add text with another leading. This can lead to some problems.", FontFactory.getFont(FontFactory.HELVETICA, 18))); - document.add(p1); - Paragraph p2 = new Paragraph(new Phrase("This is my second paragraph. ", FontFactory.getFont(FontFactory.HELVETICA, 12))); - p2.add("As you can see, it started on a new line."); - document.add(p2); - Paragraph p3 = new Paragraph("This is my third paragraph.", FontFactory.getFont(FontFactory.HELVETICA, 12)); - document.add(p3); - - PdfContentByte cb = writer.getDirectContent(); - - // Font tableFont = FontFactory.getFont(FontFactory.COURIER, - // Font.DEFAULTSIZE, Font.NORMAL); - // Font tableFont = FontFactory.getFont(FontFactory.HELVETICA, - // Font.DEFAULTSIZE, Font.NORMAL); - - BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.WINANSI, false); - Font tableFont = new Font(bf, 12); - - float padding = 0f; - Rectangle border = new Rectangle(0f, 0f); - border.setBorder(Rectangle.BOX); - border.setBorderWidth(1); - border.setBorderColor(Color.BLACK); - border.setBackgroundColor(new Color(.75f, .75f, 1f)); - PdfPTable table = makeTestPage(tableFont, border, padding, true, true); - - float width = 400; - table.setTotalWidth(width); - float height = table.getTotalHeight(); - - PdfTemplate template = cb.createTemplate(width, height); - - // we add some graphics - // template.moveTo(0, 200); - // template.lineTo(500, 0); - // template.rectangle(0, 0, width, height); - // template.setLineWidth(3); - // template.stroke(); - - table.writeSelectedRows(0, -1, 0, table.getTotalHeight(), template); - - // we add some text - // template.beginText(); - // template.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, - // BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 12); - // template.setTextMatrix(0, 0); - // template.showText("Text at the position 0,0 (relative to the - // template!)"); - // template.endText(); - - // we add the template on different positions - cb.addTemplate(template, 100, 500); - - PdfIndirectReference template_ref = template.getIndirectReference(); - System.out.println("template = " + template_ref.getNumber() + " " + template_ref.getGeneration()); - - document.close(); - - baos.close(); - byte[] pdf = baos.toByteArray(); - - // not the best solution to parse the stream, but work's for now. - String pdf_string = new String(pdf, "ISO-8859-1"); - int obj_start = pdf_string.lastIndexOf(template_ref.getNumber() + " " + template_ref.getGeneration() + " obj"); - int stream_start = pdf_string.indexOf("stream\n", obj_start) + 7; - int stream_end = pdf_string.indexOf("endstream\nendobj", stream_start); - int stream_len = stream_end - stream_start; - byte[] stream = new byte[stream_len]; - System.arraycopy(pdf, stream_start, stream, 0, stream_len); - - String stream_string = new String(stream, "ISO-8859-1"); - System.out.println(stream_string); - - List strings = Placeholder.parseStrings(pdf, stream_start, stream_end); - - List date = new ArrayList(); - List sn = new ArrayList(); - List sigval = new ArrayList(); - List issuer = new ArrayList(); - - List[] partitions = new List[] { date, sn, sigval, issuer }; - - Iterator it = strings.iterator(); - int cur_list = -1; - while (it.hasNext()) - { - StringInfo si = (StringInfo) it.next(); - - String str = si.getString("ISO-8859-1"); - - if (str.equals(KEY_DATE)) - { - cur_list = 0; - continue; - } - if (str.equals(KEY_SN)) - { - cur_list = 1; - continue; - } - if (str.equals(KEY_SIGVAL)) - { - cur_list = 2; - continue; - } - if (str.equals(KEY_ISSUER)) - { - cur_list = 3; - continue; - } - - partitions[cur_list].add(si); - } - - String date_orig = "The Date doesn't make problems."; - String sn_orig = "0123456789abcdefghijklmnopqrstuvwxyz0123456789"; - String sigval_orig = "ashdjklsbfkabsflkbadslkfblasdkfhajösdhfkjlasdhfkljasdbfljkasdhfljkasdhfljkasdhfasdfhj."; - String issuer_orig = "CN=Republik Österreich, \\\\O=Bund irgendwas, C=ÖÄÜsterreich, N=ein paar \\worte ohne (sinnn und) verstand #+ßÜ,ÄÖÜ;äöü"; - BinSig.replacePlaceholder(new SplitStrings(pdf, date), date_orig.getBytes("ISO-8859-1")); - BinSig.replacePlaceholder(new SplitStrings(pdf, sn), sn_orig.getBytes("ISO-8859-1")); - BinSig.replacePlaceholder(new SplitStrings(pdf, sigval), sigval_orig.getBytes("ISO-8859-1")); - Placeholder.replacePlaceholderWithTolerance(pdf, issuer, issuer_orig.getBytes("ISO-8859-1"), 10); - // replacePlaceholders(pdf, "CN=Seppl Maximilian Hötürälß, ÖÜÄß", (byte) - // 'Y'); - - byte [] enc = { 'w', 'i', 'n' }; - String date_rec = Placeholder.reconstructStringFromPartition(pdf, date, enc); - String sn_rec = Placeholder.reconstructStringFromPartition(pdf, sn, enc); - String sigval_rec = Placeholder.reconstructStringFromPartition(pdf, sigval, enc); - String issuer_rec = Placeholder.reconstructStringFromPartition(pdf, issuer, enc); - - System.out.println("date ok = " + date_orig.equals(date_rec)); - System.out.println("sn ok = " + sn_orig.equals(sn_rec)); - System.out.println("sigval ok = " + sigval_orig.equals(sigval_rec)); - System.out.println("issuer ok = " + issuer_orig.equals(issuer_rec)); - - FileOutputStream fos = new FileOutputStream("C:\\test.pdf"); - fos.write(pdf); - fos.close(); - - System.out.println("finished"); - - } - - private static PdfPTable makeTestPage(Font tableFont, Rectangle borders, - float padding, boolean ascender, boolean descender) throws BadElementException, DocumentException, IOException - { - // document.newPage(); - PdfPTable table = null; - table = new PdfPTable(2); - table.setWidthPercentage(100f); - - table.setWidths(new float[] { 30, 70 }); - - table.addCell(makeNormalCell(KEY_DATE)); - table.addCell(makeValueCell("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD")); - - table.addCell(makeNormalCell(KEY_SN)); - table.addCell(makeValueCell("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS")); - - table.addCell(makeNormalCell(KEY_SIGVAL)); - table.addCell(makeValueCell("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW")); - - table.addCell(makeNormalCell(KEY_ISSUER)); - table.addCell(makeValueCell("IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII")); - - return table; - } - - protected static PdfPCell makeCell(String text, int vAlignment, - int hAlignment, Font font, float leading, float padding, - Rectangle borders, boolean ascender, boolean descender) - { - Paragraph p = new Paragraph(text, font); - p.setLeading(leading); - - PdfPCell cell = new PdfPCell(p); - cell.setLeading(leading, 0); - cell.setVerticalAlignment(vAlignment); - cell.setHorizontalAlignment(hAlignment); - cell.cloneNonPositionParameters(borders); - cell.setUseAscender(ascender); - cell.setUseDescender(descender); - cell.setUseBorderPadding(true); - cell.setPadding(padding); - return cell; - } - - private static PdfPCell makeNormalCell(String text) - { - - Paragraph p = new Paragraph(text); - - PdfPCell cell = new PdfPCell(p); - cell.setBorder(PdfPCell.BOX); - cell.setBorderColor(Color.BLUE); - cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); - - return cell; - } - - private static PdfPCell makeValueCell(String placeholder) throws DocumentException, IOException - { - BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.WINANSI, false); - Font ff = new Font(bf, 12); - - Paragraph p = new Paragraph(placeholder, ff); - - PdfPCell cell = new PdfPCell(p); - cell.setBorder(PdfPCell.BOX); - cell.setBorderColor(Color.RED); - - return cell; - } - - protected boolean isPlaceholder(byte[] pdf, StringInfo si, byte placeholder) - { - for (int i = si.string_start; i < si.string_start + si.string_length; i++) - { - if (pdf[i] != placeholder) - { - return false; - } - } - return true; - } - - /** - * Replaces the given placeholders with the given bytes. - * @param ss The SplitStrings placeholders. - * @param replace_bytes The bytes to be filled in. - */ - public static void replacePlaceholder(SplitStrings ss, byte[] replace_bytes) - { - - for (int i = 0; i < replace_bytes.length; i++) - { - byte[] data = Placeholder.escapeByte(replace_bytes[i]); - if (!ss.fits(data)) - { - ss.newline(); - } - ss.write(data); - } - ss.fillRest(); - - // if (replace_read < replace_bytes.length) - // { - // System.err.println("The replace string was longer than the reserved placeholder."); - // throw new PlaceholderException(null, replace_bytes.length - replace_read); - // } - } - -} diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/test/ExtractTextTextual.java b/src/main/java/at/knowcenter/wag/egov/egiz/test/ExtractTextTextual.java deleted file mode 100644 index b79c6f3..0000000 --- a/src/main/java/at/knowcenter/wag/egov/egiz/test/ExtractTextTextual.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2006 by Know-Center, Graz, Austria - * - * This software is the confidential and proprietary information of Know-Center, - * Graz, Austria. You shall not disclose such Confidential Information and shall - * use it only in accordance with the terms of the license agreement you entered - * into with Know-Center. - * - * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF - * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR - * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY - * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. - * - * $Id: ExtractTextTextual.java,v 1.1 2006/10/31 08:19:52 wprinz Exp $ - */ -package at.knowcenter.wag.egov.egiz.test; - - -/** - * Test. - * - * @deprecated outdated - * - * @author wprinz - */ -public class ExtractTextTextual -{ - -// /** -// * @param args -// * @throws IOException -// * @throws PresentableException -// */ -// public static void main(String[] args) throws IOException, PresentableException -// { -// SettingsReader.initializeForCommandLine(); -// -// File in = new File(args[0]); -// FileInputStream fis = new FileInputStream(in); -// byte[] pdf = new byte[(int) in.length()]; -// fis.read(pdf); -// fis.close(); -// -// String text = PdfAS.extractNormalizedTextTextual(pdf, pdf.length); -// -// File out = new File(args[0] + ".txt"); -// FileOutputStream fos = new FileOutputStream(out); -// fos.write(text.getBytes("UTF-8")); -// fos.close(); -// -// System.out.println("finished. written to " + out.getAbsolutePath()); -// } - -} diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/test/X509.java b/src/main/java/at/knowcenter/wag/egov/egiz/test/X509.java deleted file mode 100644 index 059663a..0000000 --- a/src/main/java/at/knowcenter/wag/egov/egiz/test/X509.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * - */ -package at.knowcenter.wag.egov.egiz.test; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; - -/** - * @author wprinz - */ -public class X509 -{ - - /** - * @param args - * @throws CertificateException - * @throws IOException - */ - public static void main(String[] args) throws CertificateException, IOException - { - File file = new File ("C:\\tr-test.der"); - - InputStream is = new FileInputStream(file); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - X509Certificate cert = (X509Certificate)cf.generateCertificate(is); - is.close(); - - System.out.println("SerialNumber = " + cert.getSerialNumber()); - System.out.println("Issuer = " + cert.getIssuerDN().getName()); - - System.out.println("finished."); - } - -} diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/test/X509Ext.java b/src/main/java/at/knowcenter/wag/egov/egiz/test/X509Ext.java deleted file mode 100644 index 30a489b..0000000 --- a/src/main/java/at/knowcenter/wag/egov/egiz/test/X509Ext.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - */ -package at.knowcenter.wag.egov.egiz.test; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.util.Iterator; -import java.util.Set; - -/** - * @author wprinz - */ -public class X509Ext -{ - - /** - * @param args - * @throws CertificateException - * @throws IOException - */ - public static void main(String[] args) throws CertificateException, IOException - { - InputStream is = new FileInputStream("C:\\oid.der"); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - X509Certificate cert = (X509Certificate)cf.generateCertificate(is); - is.close(); - - Set oids = cert.getNonCriticalExtensionOIDs(); - Iterator it = oids.iterator(); - while (it.hasNext()) - { - String oid = (String) it.next(); - - System.out.println(oid); - } - - // Perhaps use IAIK JCE to parse this in a future version. - byte [] octet_stream = cert.getExtensionValue("1.2.40.0.10.1.1.1"); - System.out.println("octet_stream = " + octet_stream); - - } - -} -- cgit v1.2.3