aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web-client/src/test/java/at/gv/egiz
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-09-02 14:00:33 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-09-02 14:00:33 +0200
commit78fc528db30440651223b2efea95023c0fd9bc39 (patch)
tree75486d5b5a4c05cd73372752a88580b96cdb7f6a /pdf-as-web-client/src/test/java/at/gv/egiz
parent02a4a4a9b4738271cc22abf494559f39a35278e2 (diff)
downloadpdf-as-4-78fc528db30440651223b2efea95023c0fd9bc39.tar.gz
pdf-as-4-78fc528db30440651223b2efea95023c0fd9bc39.tar.bz2
pdf-as-4-78fc528db30440651223b2efea95023c0fd9bc39.zip
Test updates
Diffstat (limited to 'pdf-as-web-client/src/test/java/at/gv/egiz')
-rw-r--r--pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/BulkRequestThread.java10
-rw-r--r--pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/PerformanceTest.java6
-rw-r--r--pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java57
3 files changed, 55 insertions, 18 deletions
diff --git a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/BulkRequestThread.java b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/BulkRequestThread.java
index 6dd93ad6..7b603c18 100644
--- a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/BulkRequestThread.java
+++ b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/BulkRequestThread.java
@@ -31,7 +31,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import sun.misc.IOUtils;
+import org.apache.commons.io.IOUtils;
+
import at.gv.egiz.pdfas.api.ws.PDFASBulkSignRequest;
import at.gv.egiz.pdfas.api.ws.PDFASBulkSignResponse;
import at.gv.egiz.pdfas.api.ws.PDFASSignParameters;
@@ -59,11 +60,11 @@ public class BulkRequestThread implements Runnable {
signer = new RemotePDFSigner(endpoint, false);
FileInputStream fis = new FileInputStream(
- "/home/afitzek/Documents/arm_arm.pdf");
- inputData = IOUtils.readFully(fis, -1, true);
+ "/home/afitzek/simple.pdf");
+ inputData = IOUtils.toByteArray(fis);
signParameters = new PDFASSignParameters();
- signParameters.setConnector(Connector.JKS);
+ signParameters.setConnector(Connector.BKU);
signParameters.setPosition(null);
signParameters.setProfile("SIGNATURBLOCK_DE");
@@ -102,6 +103,7 @@ public class BulkRequestThread implements Runnable {
PDFASSignResponse bulkresponse = responses
.getSignResponses().get(j);
System.out.println("Thread: " + threadName + ", " +"ID: " + bulkresponse.getRequestID());
+ System.out.println("Thread: " + threadName + ", " +"URL: " + bulkresponse.getRedirectUrl());
if (bulkresponse.getError() != null) {
System.out.println("Thread: " + threadName + ", " + "ERROR: " + bulkresponse.getError());
} else {
diff --git a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/PerformanceTest.java b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/PerformanceTest.java
index 1654b4a0..15fbf3e4 100644
--- a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/PerformanceTest.java
+++ b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/PerformanceTest.java
@@ -33,10 +33,10 @@ public class PerformanceTest {
List<BulkRequestThread> threads = new ArrayList<BulkRequestThread>();
URL endpoint = new URL(
- "http://localhost:8080/pdf-as-web/wssign?wsdl");
+ "http://192.168.56.10/pdf-as-web/wssign?wsdl");
- for (int i = 0; i < 10; i++) {
- threads.add(new BulkRequestThread("T" + i, endpoint, 10, 10));
+ for (int i = 0; i < 2; i++) {
+ threads.add(new BulkRequestThread("T" + i, endpoint, 2, 2));
}
diff --git a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java
index 8ae2e78e..df5ba495 100644
--- a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java
+++ b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java
@@ -25,13 +25,20 @@ package at.gv.egiz.pdfas.web.client.test;
import java.io.FileInputStream;
import java.net.URL;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
-import sun.misc.IOUtils;
import at.gv.egiz.pdfas.api.ws.PDFASSignParameters;
import at.gv.egiz.pdfas.api.ws.PDFASSignParameters.Connector;
import at.gv.egiz.pdfas.api.ws.PDFASSignRequest;
import at.gv.egiz.pdfas.api.ws.PDFASSignResponse;
+import at.gv.egiz.pdfas.api.ws.PDFASVerifyRequest;
+import at.gv.egiz.pdfas.api.ws.PDFASVerifyResponse;
+import at.gv.egiz.pdfas.api.ws.PDFASVerifyResult;
+import at.gv.egiz.pdfas.api.ws.VerificationLevel;
import at.gv.egiz.pdfas.web.client.RemotePDFSigner;
+import at.gv.egiz.pdfas.web.client.RemotePDFVerifier;
public class SimpleTest {
@@ -39,10 +46,10 @@ public class SimpleTest {
try {
FileInputStream fis = new FileInputStream(
"/home/afitzek/simple.pdf");
- byte[] inputData = IOUtils.readFully(fis, -1, true);
+ byte[] inputData = IOUtils.toByteArray(fis);
PDFASSignParameters signParameters = new PDFASSignParameters();
- signParameters.setConnector(Connector.MOBILEBKU);
+ signParameters.setConnector(Connector.JKS);
signParameters.setPosition(null);
signParameters.setProfile("SIGNATURBLOCK_SMALL_DE");
@@ -53,24 +60,40 @@ public class SimpleTest {
//URL endpoint = new
//URL("http://demo.egiz.gv.at/demoportal-pdf_as/wssign?wsdl");
- URL endpoint = new
- URL("http://www.buergerkarte.at/pdf-as-extern-4/wssign?wsdl");
- //URL endpoint = new URL(
- // "http://localhost:8080/pdf-as-web/wssign?wsdl");
+ //URL endpoint = new
+ // URL("http://www.buergerkarte.at/pdf-as-extern-4/wssign?wsdl");
+ String baseUrl = "http://demo.egiz.gv.at/demoportal-pdf_as/";
+ //String baseUrl = "http://localhost:8080/pdf-as-web/";
//URL endpoint = new URL(
// "http://192.168.56.10/pdf-as-web/wssign?wsdl");
- RemotePDFSigner signer = new RemotePDFSigner(endpoint, false);
-
+ URL signEndpoint = new URL(baseUrl + "wssign?wsdl");
+ URL verifyEndpoint = new URL(baseUrl + "wsverify?wsdl");
+
+ RemotePDFSigner signer = new RemotePDFSigner(signEndpoint, true);
+ RemotePDFVerifier verifier = new RemotePDFVerifier(verifyEndpoint, true);
+
PDFASSignRequest signrequest = new PDFASSignRequest();
signrequest.setInputData(inputData);
signrequest.setParameters(signParameters);
signParameters.setTransactionId("MYID ....");
- signParameters.setPosition("f:80;w:230;p:2");
System.out.println("Simple Request:");
PDFASSignResponse response = signer.signPDFDokument(signrequest);
- System.out.println("User URL: " + response.getRedirectUrl());
+ System.out.println("Sign Error: " + response.getError());
+
+ PDFASVerifyRequest verifyRequest = new PDFASVerifyRequest();
+ verifyRequest.setInputData(response.getSignedPDF());
+ verifyRequest.setVerificationLevel(VerificationLevel.FULL_CERT_PATH);
+
+ PDFASVerifyResponse verifyResponse = verifier.verifyPDFDokument(verifyRequest);
+
+ List<PDFASVerifyResult> results = verifyResponse.getVerifyResults();
+
+ for(int i = 0; i < results.size(); i++) {
+ PDFASVerifyResult result = results.get(i);
+ printVerifyResult(result);
+ }
/*
* System.out.println("Simple Request:"); byte[] outputFile =
@@ -124,5 +147,17 @@ public class SimpleTest {
e.printStackTrace();
}
}
+
+ private static void printVerifyResult(PDFASVerifyResult result) {
+ System.out.println(result.getSignatureIndex());
+ System.out.println(" Certificate: " + result.getCertificate());
+ System.out.println(" Cert Messag: " + result.getCertificateMessage());
+ System.out.println(" Cert Code : " + result.getCertificateCode());
+ System.out.println(" Value Code : " + result.getValueCode());
+ System.out.println(" Value Messg: " + result.getValueMessage());
+ System.out.println(" SignedBy : " + result.getSignedBy());
+ System.out.println(" Processed : " + result.getProcessed());
+ System.out.println(" Signed Data: " + result.getSignedData());
+ }
}