/** * */ 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!!!!!!!"); // } // } }