/** * */ package test.at.knowcenter.wag.egov.egiz; /** * @deprecated old code * * @author wprinz * */ public class TestNeu { // private static Log logger = LogFactory.getLog(TestNeu.class); // // protected static String TEXT = "Test 123 äöüß"; //$NON-NLS-1$ // // protected static File PDF = new File("C:\\wprinz\\Filer\\egiz\\docs\\document4.pdf"); //$NON-NLS-1$ // // /** // * @param args // * @throws SignatureException // */ // public static void main(String[] args) throws Exception // { // SettingsReader.initializeForCommandLine(); // PropertyConfigurator.configure(SettingsReader.CONFIG_PATH + "log4j.properties"); //$NON-NLS-1$ // // //testEnvelopingBase64BKUConnector(); // // testEnvelopingBase64MOAConnector(); // // // testDetachedLocRefMOAConnector (); // // // testDetachedMultipartBKUConnector(); // // // testTexMOA(); // // // testBinBKU(); // // // testTexBKU(); // // // SignatureResponse sr = bku_c.doVerify(TEXT, so); // // // logger.debug("sr = " + sr); // // logger.info("finished."); // } // // public static void testEnvelopingBase64BKUConnector() throws Exception // { // Connector c = new EnvelopedBase64BKUConnector("CIO-BUND2"); //$NON-NLS-1$ // // SignatureData data = new BinarySignatureData(); // // { // SignSignatureObject so = c.doSign(data); // // FileOutputStream fos = new FileOutputStream("C:\\wprinz\\Filer\\egiz2\\SignatureObject.bin"); // ObjectOutputStream oos = new ObjectOutputStream(fos); // oos.writeObject(so); // oos.close(); // } // // { // FileInputStream fis = new FileInputStream("C:\\wprinz\\Filer\\egiz2\\SignatureObject.bin"); // ObjectInputStream ois = new ObjectInputStream(fis); // SignSignatureObject so = (SignSignatureObject) ois.readObject(); // ois.close(); // // SignatureResponse sr = c.doVerify(data, so); // // logger.debug("sr = " + sr); // } // } // // public static void testEnvelopingBase64MOAConnector() throws Exception // { // Connector c = new EnvelopingBase64MOAConnector("CIO-BUND2"); //$NON-NLS-1$ // // SignatureData data = new BinarySignatureData(); // // { // SignSignatureObject so = c.doSign(data); // // FileOutputStream fos = new FileOutputStream("C:\\wprinz\\Filer\\egiz2\\SignatureObject.bin"); // ObjectOutputStream oos = new ObjectOutputStream(fos); // oos.writeObject(so); // oos.close(); // } // // { // FileInputStream fis = new FileInputStream("C:\\wprinz\\Filer\\egiz2\\SignatureObject.bin"); // ObjectInputStream ois = new ObjectInputStream(fis); // SignSignatureObject so = (SignSignatureObject) ois.readObject(); // ois.close(); // // SignatureResponse sr = c.doVerify(data, so); // logger.debug("sr = " + sr); // } // } // //// public static void testDetachedLocRefMOAConnector() throws Exception //// { //// DetachedLocRefMOAConnector c = new DetachedLocRefMOAConnector("CIO-BUND2"); //$NON-NLS-1$ //// //// SignatureData data = new TextSignatureData(); //// //// SignSignatureObject so = c.doSign(data); //// //// } // // public static void testDetachedMultipartBKUConnector() throws Exception // { // DetachedBKUConnector c = new MultipartDetachedBKUConnector("CIO-BUND2"); //$NON-NLS-1$ // // SignatureData data = new BinarySignatureData(); // // SignSignatureObject so = c.doSign(data); // // FileOutputStream fos = new FileOutputStream("C:\\wprinz\\Filer\\egiz2\\SignatureObject.bin"); // ObjectOutputStream oos = new ObjectOutputStream(fos); // oos.writeObject(so); // oos.close(); // // FileInputStream fis = new FileInputStream("C:\\wprinz\\Filer\\egiz2\\SignatureObject.bin"); // ObjectInputStream ois = new ObjectInputStream(fis); // so = (SignSignatureObject) ois.readObject(); // ois.close(); // // SignatureResponse sr = c.doVerify(data, so); // logger.debug("sr = " + sr); // // } // // public static void testBinBKU() throws Exception // { // FileInputStream fis = new FileInputStream(PDF); // byte[] data = new byte[(int) PDF.length()]; // fis.read(data); // fis.close(); // // PdfASID algorithm = new PdfASID("urn:pdfsigfilter:bka.gv.at:binaer:v1.0.0"); // // SignatureObject so = testSignBKU(data, algorithm); // // so.setKZ(algorithm); // // SignatureResponse sr = testVerifyBKU(data, so); // // logger.debug("sr = " + sr); // // } // // public static void testTexBKU() throws Exception // { // PdfASID algorithm = new PdfASID("urn:pdfsigfilter:bka.gv.at:text:v1.0.0"); // // SignatureObject so = testSignBKU(TEXT.getBytes("UTF-8"), algorithm); // // so.setKZ(algorithm); // // // FileOutputStream fos = new // // FileOutputStream("C:\\wprinz\\Filer\\egiz2\\SignatureObject.bin"); // // ObjectOutputStream oos = new ObjectOutputStream(fos); // // oos.writeObject(so); // // oos.close(); // // SignatureResponse sr = testVerifyBKU(TEXT.getBytes("UTF-8"), so); // // logger.debug("sr = " + sr); // } // // public static void testTexMOA() throws Exception // { // PdfASID algorithm = new PdfASID("urn:pdfsigfilter:bka.gv.at:text:v1.0.0"); // // SignatureObject so = testSignMOA(TEXT.getBytes("UTF-8"), algorithm); // // so.setKZ(algorithm); // // // FileOutputStream fos = new // // FileOutputStream("C:\\wprinz\\Filer\\egiz2\\SignatureObject.bin"); // // ObjectOutputStream oos = new ObjectOutputStream(fos); // // oos.writeObject(so); // // oos.close(); // // // SignatureResponse sr = testVerifyBKU(TEXT.getBytes("UTF-8"), so); // // // // logger.debug("sr = " + sr); // } // // public static SignatureObject testSignBKU(byte[] data, PdfASID algorithm) throws Exception // { // BKUConnector bku_c = new BKUConnector(); // // SignatureObject so = bku_c.doSign("CIO-BUND2", data, algorithm); // // logger.debug("so = " + so); // // return so; // } // // public static SignatureObject testSignMOA(byte[] data, PdfASID algorithm) throws Exception // { // MOAConnector moa_c = new MOAConnector(); // // SignatureObject so = moa_c.doSign("CIO-BUND2", data, algorithm); // // logger.debug("so = " + so); // // return so; // } // // public static SignatureResponse testVerifyBKU(byte[] data, SignatureObject so) throws Exception // { // BKUConnector bku_c = new BKUConnector(); // // SignatureResponse sr = bku_c.doVerify(data, so); // // logger.debug("sr = " + sr); // // return sr; // } // // /** // * A data source for text data. // * // * @author wprinz // */ // public static class TextSignatureData implements SignatureData // { // /** // * @see at.knowcenter.wag.egov.egiz.sig.SignatureData#getData() // */ // public byte[] getData() // { // try // { // return TEXT.getBytes(getCharacterEncoding()); // } // catch (UnsupportedEncodingException e) // { // e.printStackTrace(); // return null; // } // } // // /** // * @see at.knowcenter.wag.egov.egiz.sig.SignatureData#getMimeType() // */ // public String getMimeType() // { // return "text/plain"; //$NON-NLS-1$ // } // // /** // * @see at.knowcenter.wag.egov.egiz.sig.SignatureData#getCharacterEncoding() // */ // public String getCharacterEncoding() // { // return "UTF-8"; //$NON-NLS-1$ // } // } // // /** // * A data source for binary (PDF) data. // * // * @author wprinz // */ // public static class BinarySignatureData implements SignatureData // { // /** // * @see at.knowcenter.wag.egov.egiz.sig.SignatureData#getData() // */ // public byte[] getData() // { // try // { // FileInputStream fis = new FileInputStream(PDF); // byte[] data = new byte[(int) PDF.length()]; // fis.read(data); // fis.close(); // // return data; // } // catch (Exception e) // { // e.printStackTrace(); // return null; // } // } // // /** // * @see at.knowcenter.wag.egov.egiz.sig.SignatureData#getMimeType() // */ // public String getMimeType() // { // return "application/pdf"; //$NON-NLS-1$ // } // // /** // * @see at.knowcenter.wag.egov.egiz.sig.SignatureData#getCharacterEncoding() // */ // public String getCharacterEncoding() // { // return null; // } // // } }