From 133a3fc5c68b11c5ed03438e409d6dc49cbd6771 Mon Sep 17 00:00:00 2001 From: knowcenter Date: Wed, 16 May 2007 19:58:30 +0000 Subject: enveloping connectors git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@79 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../test/at/knowcenter/wag/egov/egiz/TestNeu.java | 80 ++++++++++++++++++++-- 1 file changed, 75 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/test/java/test/at/knowcenter/wag/egov/egiz/TestNeu.java b/src/test/java/test/at/knowcenter/wag/egov/egiz/TestNeu.java index 84fda4c..c35d640 100644 --- a/src/test/java/test/at/knowcenter/wag/egov/egiz/TestNeu.java +++ b/src/test/java/test/at/knowcenter/wag/egov/egiz/TestNeu.java @@ -22,9 +22,12 @@ import at.knowcenter.wag.egov.egiz.exceptions.SignatureException; import at.knowcenter.wag.egov.egiz.sig.SignatureData; import at.knowcenter.wag.egov.egiz.sig.SignatureObject; import at.knowcenter.wag.egov.egiz.sig.SignatureResponse; +import at.knowcenter.wag.egov.egiz.sig.connectors.Connector; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.DetachedMultipartBKUConnector; +import at.knowcenter.wag.egov.egiz.sig.connectors.bku.EnvelopedBase64BKUConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject; -import at.knowcenter.wag.egov.egiz.tools.FileHelper; +import at.knowcenter.wag.egov.egiz.sig.connectors.moa.DetachedLocRefMOAConnector; +import at.knowcenter.wag.egov.egiz.sig.connectors.moa.EnvelopingBase64MOAConnector; /** * @author wprinz @@ -35,9 +38,8 @@ 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$ + protected static File PDF = new File("C:\\wprinz\\Filer\\egiz\\docs\\document4.pdf"); //$NON-NLS-1$ /** * @param args @@ -48,7 +50,13 @@ public class TestNeu SettingsReader.initializeForCommandLine(); PropertyConfigurator.configure(SettingsReader.CONFIG_PATH + "log4j.properties"); //$NON-NLS-1$ - testDetachedMultipartBKUConnector(); + //testEnvelopingBase64BKUConnector(); + + testEnvelopingBase64MOAConnector(); + + // testDetachedLocRefMOAConnector (); + + // testDetachedMultipartBKUConnector(); // testTexMOA(); @@ -63,6 +71,68 @@ public class TestNeu logger.info("finished."); } + public static void testEnvelopingBase64BKUConnector() throws Exception + { + Connector c = new EnvelopedBase64BKUConnector("CIO-BUND2"); //$NON-NLS-1$ + + SignatureData data = new TextSignatureData(); + + { + 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 TextSignatureData(); + + { + 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 { DetachedMultipartBKUConnector c = new DetachedMultipartBKUConnector("CIO-BUND2"); //$NON-NLS-1$ @@ -234,7 +304,7 @@ public class TestNeu byte[] data = new byte[(int) PDF.length()]; fis.read(data); fis.close(); - + return data; } catch (Exception e) -- cgit v1.2.3