summaryrefslogtreecommitdiff
path: root/eaaf_modules
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-04-06 09:54:23 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-04-06 09:54:23 +0200
commit68e96ea339f58efb772b4ad77f617347aeb1ce71 (patch)
tree57c285f61a2fae2fc8bf55f6970b76d5af520778 /eaaf_modules
parent3b5f84e413694270f54e5f47d8130276b02a463a (diff)
downloadEAAF-Components-68e96ea339f58efb772b4ad77f617347aeb1ce71.tar.gz
EAAF-Components-68e96ea339f58efb772b4ad77f617347aeb1ce71.tar.bz2
EAAF-Components-68e96ea339f58efb772b4ad77f617347aeb1ce71.zip
add test to moa-sig module that facilities decoding of PDF embeded CAdES signatures
Diffstat (limited to 'eaaf_modules')
-rw-r--r--eaaf_modules/eaaf_module_moa-sig/src/test/java/console/PdfSigDecoder.java40
-rw-r--r--eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_1.hex1
-rw-r--r--eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_2.hex1
-rw-r--r--eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_3.hex1
4 files changed, 43 insertions, 0 deletions
diff --git a/eaaf_modules/eaaf_module_moa-sig/src/test/java/console/PdfSigDecoder.java b/eaaf_modules/eaaf_module_moa-sig/src/test/java/console/PdfSigDecoder.java
new file mode 100644
index 00000000..28338746
--- /dev/null
+++ b/eaaf_modules/eaaf_module_moa-sig/src/test/java/console/PdfSigDecoder.java
@@ -0,0 +1,40 @@
+package console;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.springframework.util.Base64Utils;
+import org.springframework.util.StreamUtils;
+
+import iaik.asn1.ASN1;
+import iaik.asn1.CodingException;
+
+public class PdfSigDecoder {
+
+ /**
+ * Decode a CAdES signature that is located in a PDF document.
+ *
+ * @param args not supported yes
+ * @throws CodingException In case of an ASN.1 decoding error
+ * @throws IOException In case of a general error
+ * @throws UnsupportedEncodingException In case of a general error
+ */
+ public static void main(String[] args) throws CodingException, UnsupportedEncodingException, IOException {
+ InputStream is = PdfSigDecoder.class.getResourceAsStream("/pdf_cades_3.hex");
+ String test = new String(StreamUtils.copyToByteArray(is), "UTF-8");
+ test = test.replaceAll("\\n", "");
+ final byte[] bytes = new byte[test.length() / 2];
+ for (int i = 0; i < test.length() / 2; i++) {
+ bytes[i] = (byte) Integer.parseInt(test.substring(i * 2, i * 2 + 2), 16);
+ }
+ Base64Utils.encodeToString(bytes);
+
+ final ASN1 asn1 = new ASN1(bytes);
+
+ System.out.println(asn1.toString());
+ System.out.println(Base64Utils.encodeToString(bytes));
+
+ }
+
+}
diff --git a/eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_1.hex b/eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_1.hex
new file mode 100644
index 00000000..32861d68
--- /dev/null
+++ b/eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_1.hex
@@ -0,0 +1 @@
+3082065406092A864886F70D010702A082064530820641020101310B300906052B240302010500300B06092A864886F70D010701A08204B3308204AF30820397A00302010202030E6CBE300D06092A864886F70D0101050500308197310B300906035504061302415431483046060355040A0C3F412D5472757374204765732E20662E20536963686572686569747373797374656D6520696D20656C656B74722E20446174656E7665726B65687220476D6248311E301C060355040B0C15612D7369676E2D5072656D69756D2D5369672D3032311E301C06035504030C15612D7369676E2D5072656D69756D2D5369672D3032301E170D3133303431303130343633335A170D3138303431303038343633335A305E310B30090603550406130241543116301406035504030C0D41726D696E20466973636865723110300E06035504040C0746697363686572310E300C060355042A0C0541726D696E311530130603550405130C3933373131343838363833343059301306072A8648CE3D020106082A8648CE3D03010703420004BF7ADE98B7CD89A0559F2BA9463454E08DBE3516A86BB7B8F4FDBB42FF24A03991AF5BD63D72197F63AB03C88260C31E4A9C17DB5E8681FCAE1D7CF90EB1ACD1A38202053082020130110603551D0E040A0408433A176E9B70B5CD300E0603551D0F0101FF0404030206C030130603551D23040C300A80084DDFE1FF4BD9C9DF301E0603551D1104173015811361726D696E40666973636865722E6F722E617430090603551D1304023000307B06082B06010505070101046F306D304206082B060105050730028636687474703A2F2F7777772E612D74727573742E61742F63657274732F612D7369676E2D5072656D69756D2D5369672D3032612E637274302706082B06010505073001861B687474703A2F2F6F6373702E612D74727573742E61742F6F63737030590603551D2004523050304406062A280011010B303A303806082B06010505070201162C687474703A2F2F7777772E612D74727573742E61742F646F63732F63702F612D7369676E2D5072656D69756D3008060604008B300101302706082B060105050701030101FF041830163008060604008E460101300A06082B06010505070B0130819A0603551D1F04819230818F30818CA08189A081868681836C6461703A2F2F6C6461702E612D74727573742E61742F6F753D612D7369676E2D5072656D69756D2D5369672D30322C6F3D412D54727573742C633D41543F63657274696669636174657265766F636174696F6E6C6973743F626173653F6F626A656374636C6173733D65696443657274696669636174696F6E417574686F72697479300D06092A864886F70D01010505000382010100352830958A68A260CFEFB1DA157C1452E22735A2BBC40F51A19D22481766537630C8E0C99CCE50F614E437ABFF943C7D6A69CCB0F79ED6A9B5356182DFBA095F3534671073D586F70B002CEF846E6D4447031AFBFE5D727D2A893688294D494C37454C187F15611EFDFA84D64D0C9D4E3EC9FF8A126A842EDB70D1F9AD497A1A11CC1363AAFD76D7412F21248B855363D3AB771C538D5610BC7F0FCEA359F33F5FA6A228E0539C16AF12A1B2DE608719CBE39C41AFE5BD0CDDC781F00C6A86B21BA252DD23DAEBB3B91CADE8278B330945CA11D4A77188197E744BA9B5288E9D4A4C7502D706D7CEA569D258E116E6ACE42F4C24449803076C30A7BABE26CAE7318201693082016502010130819F308197310B300906035504061302415431483046060355040A0C3F412D5472757374204765732E20662E20536963686572686569747373797374656D6520696D20656C656B74722E20446174656E7665726B65687220476D6248311E301C060355040B0C15612D7369676E2D5072656D69756D2D5369672D3032311E301C06035504030C15612D7369676E2D5072656D69756D2D5369672D303202030E6CBE300906052B240302010500A05F301806092A864886F70D010903310B06092A864886F70D010701301E06092A864886F70D0109053111180F32303137303631393130303130305A302306092A864886F70D010904311604149D0A3FDC7F8CED863952B468C927AC87CE227B68300E060A04007F0007010104010605000440002B459189C71E69CC13E111ED1F493D89681E0A815CCEA297AC3D76A48A75E7D11081F08D7A0FAA4210205D2B8A0A7A83E0F5211AD51BDE2581D4C4E400C06AA1000000000000000000000
diff --git a/eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_2.hex b/eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_2.hex
new file mode 100644
index 00000000..0249d79c
--- /dev/null
+++ b/eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_2.hex
@@ -0,0 +1 @@
+308006092a864886f70d010702a0803080020101310f300d06096086480165030402010500308006092a864886f70d0107010000a08204953082049130820379a0030201020203133594300d06092a864886f70d0101050500308197310b300906035504061302415431483046060355040a0c3f412d5472757374204765732e20662e20536963686572686569747373797374656d6520696d20656c656b74722e20446174656e7665726b65687220476d6248311e301c060355040b0c15612d7369676e2d5072656d69756d2d5369672d3032311e301c06035504030c15612d7369676e2d5072656d69756d2d5369672d3032301e170d3134303530323039303734395a170d3139303530323039303734395a3060310b30090603550406130241543117301506035504030c0e4d6178204d75737465726d616e6e3113301106035504040c0a4d75737465726d616e6e310c300a060355042a0c034d6178311530130603550405130c3237333736313333323837363059301306072a8648ce3d020106082a8648ce3d03010703420004f7be38b8b730fd5ab3b62a54de3ca256f0f81c0b99116affce3326258448a23a1406207d6e9a8b217fee06466d43d7bed6cbf27c4e3049600576b66f8836a5f3a38201e5308201e130110603551d0e040a04084daa6d7cb1103d48300e0603551d0f0101ff0404030206c030130603551d23040c300a80084ddfe1ff4bd9c9df30090603551d1304023000307b06082b06010505070101046f306d304206082b060105050730028636687474703a2f2f7777772e612d74727573742e61742f63657274732f612d7369676e2d5072656d69756d2d5369672d3032612e637274302706082b06010505073001861b687474703a2f2f6f6373702e612d74727573742e61742f6f63737030590603551d2004523050304406062a280011010b303a303806082b06010505070201162c687474703a2f2f7777772e612d74727573742e61742f646f63732f63702f612d7369676e2d5072656d69756d3008060604008b300101302706082b060105050701030101ff041830163008060604008e460101300a06082b06010505070b0130819a0603551d1f04819230818f30818ca08189a081868681836c6461703a2f2f6c6461702e612d74727573742e61742f6f753d612d7369676e2d5072656d69756d2d5369672d30322c6f3d412d54727573742c633d41543f63657274696669636174657265766f636174696f6e6c6973743f626173653f6f626a656374636c6173733d65696443657274696669636174696f6e417574686f72697479300d06092a864886f70d01010505000382010100cd7da6254ccf3aec8479bddc2539ceb9ef591a1b51d8757bb6851d2974c909ada603ec18cf96da6a829ca71a6e55d84855f4d7e34776dc1b709c551e466069d6f3e1b805491ef86a9ac3e95ad871d3d382eab50e9268ea0b7312e40304d8215c6c42e5a101a73f839f47aa55ef47642c471d9e1852c6a67c5b0b6aab13d0e7340c0fdfc284a90ee1460baf17cab1d1eecfb513704fdd2460e65dd56fb644e19cc0a80883f31da1d4872809797964e6dc3bd6e09beb45ebc39abcb9356f564f24e2b01fdd9aa6b5353c8ee37f6938fc4b7de1480b4889c9a9b16d16a161db060fb0aa3681175209b7e48b9892c6de847eb76c5122f0543e637b7bc259a8507b883182010d3082010902010130819f308197310b300906035504061302415431483046060355040a0c3f412d5472757374204765732e20662e20536963686572686569747373797374656d6520696d20656c656b74722e20446174656e7665726b65687220476d6248311e301c060355040b0c15612d7369676e2d5072656d69756d2d5369672d3032311e301c06035504030c15612d7369676e2d5072656d69756d2d5369672d30320203133594300d06096086480165030402010500300b06072a8648ce3d0201050004463044022079c3a32116fba799d77df0458e88f1d3370251382030f8d54f136afbe6635c39022072dc7bc7411a96b47717817f9c851954f6b511a30e47944221acc985bab6502b00000000000000000
diff --git a/eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_3.hex b/eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_3.hex
new file mode 100644
index 00000000..eb2bcd07
--- /dev/null
+++ b/eaaf_modules/eaaf_module_moa-sig/src/test/resources/pdf_cades_3.hex
@@ -0,0 +1 @@
+3082068506092A864886F70D010702A082067630820672020101310F300D06096086480165030402010500300B06092A864886F70D010701A0820486308204823082042CA00302010202040AF54A4A300D060960864801650304030205003042310B3009060355040613024154310F300D060355040A130654554772617A310C300A060355040B1303565055311430120603550403130B446576656C6F706D656E74301E170D3230303330323130353735395A170D3230303533313130353735395A3042310B3009060355040613024154310F300D060355040A130654554772617A310C300A060355040B1303565055311430120603550403130B446576656C6F706D656E74308203433082023506072A8648CE3804013082022802820101008F7935D9B9AAE9BFABED887ACF4951B6F32EC59E3BAF3718E8EAC4961F3EFD3606E74351A9C4183339B809E7C2AE1C539BA7475B85D011ADB8B47987754984695CAC0E8F14B3360828A22FFA27110A3D62A993453409A0FE696C4658F84BDD20819C3709A01057B195ADCD00233DBA5484B6291F9D648EF883448677979CEC04B434A6AC2E75E9985DE23DB0292FC1118C9FFA9D8181E7338DB792B730D7B9E349592F68099872153915EA3D6B8B4653C633458F803B32A4C2E0F27290256E4E3F8A3B0838A1C450E4E18C1A29A37DDF5EA143DE4B66FF04903ED5CF1623E158D487C608E97F211CD81DCA23CB6E380765F822E342BE484C05763939601CD667021D00BAF696A68578F7DFDEE7FA67C977C785EF32B233BAE580C0BCD5695D0282010016A65C58204850704E7502A39757040D34DA3A3478C154D4E4A5C02D242EE04F96E61E4BD0904ABDAC8F37EEB1E09F3182D23C9043CB642F88004160EDF9CA09B32076A79C32A627F2473E91879BA2C4E744BD2081544CB55B802C368D1FA83ED489E94E0FA0688E32428A5C78C478C68D0527B71C9A3ABB0B0BE12C44689639E7D3CE74DB101A65AA2B87F64C6826DB3EC72F4B5599834BB4EDB02F7C90E9A496D3A55D535BEBFC45D4F619F63F3DEDBB873925C2F224E07731296DA887EC1E4748F87EFB5FDEB75484316B2232DEE553DDAF02112B0D1F02DA30973224FE27AEDA8B9D4B2922D9BA8BE39ED9E103A63C52810BC688B7E2ED4316E1EF17DBDE0382010600028201010080B0130F8F50B805700EABB2FF2A446B06BC19E5C8A25D157B97C0C9C1938F2FFDEA6DCE089B9E31E9DD3F5DA56CF9C337F865F57768E25057A949014B02AF994AD398628AE56F167F4B1699F8ABACA88B26C069EE478F8CAD237E7E064D892C15E689ED0C4ECDBF20F417ECF9F2800073A931D226A1989C6E698E2D52CAE29A2AB649A39596573984747B634AC29D58506733143E42275FD10AB9EF626AAB24B79FF754C9BA37C301DC1FDB1FB6DE194FF2B0C4FB0A1648E6964E783822C72364911B07D98D321F5A6FB7DF1B9E36B555779059571A6BF3707CB59C771D8DA88F260262CE72C2766DAF6BC4FF25186FDEF2E32B4DFE1E4883605C5F7256698AA321301F301D0603551D0E0416041455AF75C427FF15D0C79D2E5384BC59857D2EB867300D06096086480165030403020500034100303E021D00948ED8B1A1CC4F4C30D49AA6AF6F394F98CFF50A1D3B0183EE667349021D009C6FA5F30E402CBD0C84C5CE28BD99F8445412BFA824503295BC0187318201C3308201BF020101304A3042310B3009060355040613024154310F300D060355040A130654554772617A310C300A060355040B1303565055311430120603550403130B446576656C6F706D656E7402040AF54A4A300D06096086480165030402010500A0820110301806092A864886F70D010903310B06092A864886F70D010701301B060604008D45020131110C0F6170706C69636174696F6E2F706466301C06092A864886F70D010905310F170D3230303332353039303035355A302F06092A864886F70D01090431220420985FFC8BF244B1D0974C4507D5B94248D41CDF628E8CC251DCFA8EA09D4E42B0308187060B2A864886F70D010910022F31783076307430720420E1F0438DF6BE5BE71D44D6356E577A535B430E3E0B83BCC8C40BFEC7E0181468304E3046A4443042310B3009060355040613024154310F300D060355040A130654554772617A310C300A060355040B1303565055311430120603550403130B446576656C6F706D656E7402040AF54A4A300B0609608648016503040302043E303C021C4AC36A2568A8C095B891708C2A0D492AEB9A38A907F3DA2C9D423517021C45C82CCD994A9BD64B1AF643DA2AA2663DBBE7865DF1D0CE31D2DA9C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000